package ext.generic.util;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.Properties;
import wt.util.WTException;

/**
 * 通用的properties文件读取属性项的方法类
 */
public class Generic {

	public static Object getStrFromProperties(String key, String propertiefile)
			throws WTException, UnsupportedEncodingException {
		Properties pros = new Properties();
		Object value = null;
		try {
			pros.load(new InputStreamReader(Object.class 
					.getResourceAsStream(propertiefile),"UTF-8"));
			System.out.println("key : " + key);
			value = pros.get(key.toString());
			System.out.println("value:" + value);
		} catch (IOException e) {
			e.getMessage();
		}
		return value;
	}

	/**
	 * @param args
	 * @throws WTException
	 * @throws UnsupportedEncodingException
	 */
	public static void main(String[] args) throws UnsupportedEncodingException,
			WTException {
		/*
		 * if( args == null || args.length != 1 ){ return; }
		 */
		System.out.println("Debug   getStrFromProperties...");
		/*System.out.println(getStrFromProperties("背光模组.是",
				"ext.generic.workflow.workflowParticipant"));*/
		System.out.println(getStrFromProperties("BLU.PMPI_ASSESSOR","/ext/tianma/cfg/TianmaPro.properties"));
		System.out.println("Debug   end getStrFromProperties...");

	}

}
